package cn.wolfcode.p2p.mgrsite.web.controller;

import cn.wolfcode.p2p.base.domain.LoginInfo;
import cn.wolfcode.p2p.base.query.VideoAuthQuery;
import cn.wolfcode.p2p.base.service.IVideoAuthService;
import cn.wolfcode.p2p.base.util.JSONResult;
import cn.wolfcode.p2p.base.util.LoginInfoContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 后台视频认证平台
 */
@Controller
public class VideoAuthController {

    @Autowired
    private IVideoAuthService videoAuthService;

    @RequestMapping("/videoAuth")
    public String listVideoAuth(Model model, @ModelAttribute("qo") VideoAuthQuery qo){
        // 判断是否是超级管理员
        LoginInfo current = LoginInfoContext.getCurrentLoginInfo();
        if (!current.isAdmin()){
            // 设置审核人id
            qo.setAuditorId(current.getId());
        }
        model.addAttribute("pageInfo", videoAuthService.query(qo));

        return "videoAuth/list";
    }

    @RequestMapping("/videoAuth_audit")
    @ResponseBody
    public JSONResult auditVideoAuth(Long videoAuthId, Integer state, String remark){

        videoAuthService.auditVideoAuth(videoAuthId, state, remark);

        return new JSONResult();
    }
}
